package com.learn.databinding

import android.content.Context
import android.util.Log
import android.view.View
import android.widget.Toast
import com.exercise.struct.base.BaseDataBindingActivity
import com.learn.databinding.bindingadapters.BindingAdaptersActivity
import com.learn.databinding.workwithobservabledataobjects.bindlayoutwithlivedata.BindLayoutWithLiveDataActivity
import com.learn.databinding.databinding.ActivityMainBinding
import com.learn.databinding.layoutandbindingexpression.LayoutAndBindingExpressionActivity
import com.learn.databinding.workwithobservabledataobjects.WorkWithObservableDataObjectActivity
import com.learn.databinding.workwithobservabledataobjects.bindlayoutwithstateflow.BindLayoutWithStateFlowActivity

class MainActivity : BaseDataBindingActivity<ActivityMainBinding>() {

    override val layoutResId: Int
        get() = R.layout.activity_main

    override fun setToolbar() {
    }

    override fun initView() {
        mDataBinding.handlers = MyHandlers()
    }

    /**
     * 事件处理类
     */
    inner class MyHandlers {
        /**
         * 时间处理方法
         * 注意：方法签名要和引用的方法签名一致
         */
        fun onClickTest(view: View) {
            LayoutAndBindingExpressionActivity.start(view.context)
        }
        fun onClickWorkWithObservableData(context: Context){
            WorkWithObservableDataObjectActivity.start(context)
        }
        fun onClickBindLayoutWithLiveData(context: Context){
            BindLayoutWithLiveDataActivity.start(context)
        }
        fun onClickBindLayoutWithStateFlow(context: Context){
            BindLayoutWithStateFlowActivity.start(context)
        }
        fun onClickBindingAdapters(context: Context){
            BindingAdaptersActivity.start(context)
        }
    }
}